package com.talos.ums.dal.mysql.roleresource;

import com.talos.framework.common.pojo.PageResult;
import com.talos.framework.mybatis.core.mapper.BaseMapperX;
import com.talos.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.talos.ums.controller.admin.roleresource.vo.UmsRoleResourcePageReqVO;
import com.talos.ums.dal.dataobject.roleresource.UmsRoleResourceDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 角色菜单关联表 Mapper
 *
 * @author ${table.author}
 */
@Mapper
public interface UmsRoleResourceMapper extends BaseMapperX<UmsRoleResourceDO> {

    default PageResult<UmsRoleResourceDO> selectPage(UmsRoleResourcePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UmsRoleResourceDO>()
                .eqIfPresent(UmsRoleResourceDO::getRoleId, reqVO.getRoleId())
                .eqIfPresent(UmsRoleResourceDO::getResourceId, reqVO.getResourceId())
                .eqIfPresent(UmsRoleResourceDO::getRoleCode, reqVO.getRoleCode())
                .eqIfPresent(UmsRoleResourceDO::getResourceCode, reqVO.getResourceCode())
                .eqIfPresent(UmsRoleResourceDO::getCreatorCode, reqVO.getCreatorCode())
                .likeIfPresent(UmsRoleResourceDO::getCreatorName, reqVO.getCreatorName())
                .betweenIfPresent(UmsRoleResourceDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(UmsRoleResourceDO::getModifierCode, reqVO.getModifierCode())
                .likeIfPresent(UmsRoleResourceDO::getModifierName, reqVO.getModifierName())
                .betweenIfPresent(UmsRoleResourceDO::getModifyTime, reqVO.getModifyTime())
                .eqIfPresent(UmsRoleResourceDO::getTenantId, reqVO.getTenantId())
                .eqIfPresent(UmsRoleResourceDO::getCreatorId, reqVO.getCreatorId())
                .eqIfPresent(UmsRoleResourceDO::getModifierId, reqVO.getModifierId())
                .orderByDesc(UmsRoleResourceDO::getId));
    }

}
